feat(spec): port getAddressInfoByCep to the bridge - #583
hyanmandian wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The utility that decides whether the engine is real. It reaches the network, parses JSON,
retries a transient failure, races three providers and raises one of four errors depending
on how they fail — and none of that is written per target.
The source is straight-line and synchronous. The compiler works out that the call graph
waits on the network and colours it: TypeScript and C# come out `async`, with a `Promise`
and a `Task`; Go, Rust, Ruby, Java and Python stay blocking. `throw` becomes a real
exception class in five targets, `(T, error)` in Go and `Result<T, runtime::Error>` in Rust,
with the declared hierarchy intact in all seven. `startAll` becomes promises, `Task`s,
goroutines and a channel, threads and an `mpsc`, virtual threads, and threads with a queue.
The recorder carries both sides of the same scenario table: recording stubs `fetch` the way
the JavaScript suite does, and replaying serves the same answers over real HTTP, so each
target runs through its own client. Fourteen scenarios cover a provider that answers, one
that misses, one that is down, a body that is not an object, fields that are not strings, a
masked CEP, and the flags that disagree with the body.
typescript 110/110 python 109/109 ruby 109/109
go 103/103 rust 103/103 java 103/103 csharp 103/103
Python and Ruby cannot be handed `{ providers: null }`, because `None` and `nil` are also
what an omitted option looks like; the five compiled targets cannot be handed a numeric CEP
or a `providers` that is not a list at all. The C ABI does not carry this one: a function
that raises and waits needs more than pointers and integers, and it is refused rather than
guessed at.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UX1gTGeMTyoXQyr1qUoQKd
b51853d to
dbff7d8
Compare
8c23e92 to
3cd2385
Compare
Tree-shaking report✅ No bundle size impact. All 155 exports are the same size as on the base branch (full import 648.9 KB, gzip 166.2 KB). All exports (155)
How this is measuredEvery export is imported alone into an esbuild consumer bundle (minified, tree-shaken) built from the head and from the base of this pull request; the sizes are the resulting bundles, gzip is their gzipped size. 🔴 marks a regression: a pre-existing export that grew more than 20% and more than 256 B, or the bundle importing every pre-existing export growing more than 5%. 🟡 is growth under the threshold, 🟢 a decrease, ⚪ no change, 🆕 an export that does not exist on the base (never a regression), 🗑️ an export that was removed. An intentional increase is accepted with the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude/bridge-format-cnpj #583 +/- ##
===========================================================
Coverage 100.00% 100.00%
===========================================================
Files 183 183
Lines 2069 2069
Branches 612 612
===========================================================
Hits 2069 2069
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The red If Codecov reports a "missing BASE report" on this one, that is an artifact of the stack rather than a regression: the base is Everything on GitHub Actions is green or still running. Generated by Claude Code |
What does this PR do?
Stacked on #582 → #581 → #580 (the compiler). This PR's diff is only what
getAddressInfoByCepadds.The utility that decides whether the engine is real. It reaches the network, parses JSON, retries a transient failure, races three providers and raises one of four errors depending on how they fail — and none of that is written per target.
The diff, in full
source/get-address-info-by-cep.tsconformance/cases/get-address-info-by-cep.tsfetchstub for recording and an HTTP server for replayingNo compiler change.
What the author wrote, and what came out
The source is straight-line and synchronous. Everything below is the emitter's:
async/Promiseasync/Task(T, error)Result<T, runtime::Error>TasksmpscThe declared error hierarchy —
ValidationError,NotFoundErrorandServiceErrorall extendingGetAddressInfoByCepError— survives in all seven, including in Go and Rust, where a failure carries its kinds soerrors.Asanderror.kind()answer the same question acatchdoes.One table, both sides
Recording stubs
fetchexactly as the JavaScript suite does. Replaying serves the same answers over real HTTP, so each target runs through its own client, its own JSON reader and its own scheduler rather than a stub. The scenarios cover a provider that answers, one that misses, one that is down, a body that is not an object at all, fields that are not strings, a masked CEP, an empty CEP in the body, and flags that disagree with the body.bash spec/bridge/conformance/run-all.sh:Python and Ruby cannot be handed
{ providers: null }, becauseNoneandnilare also what an omitted option looks like — only TypeScript keeps the difference. The compiled targets additionally cannot be handed a numeric CEP or aprovidersthat is not a list at all.The C ABI does not carry this one. A function that raises needs an out parameter for the error and one that waits needs a callback or a poll, so the ABI emitter refuses it and says why in the generated file, rather than guessing.
bash spec/bridge/conformance/verify-typescript.sh, now three utilities:Those include the type-level assertions:
getAddressInfoByCephas to resolve toAddressInfo, and the four error classes have to extend one another.Checklist
npm test) — not applicable: no change tosrc/. The generated output is checked against the package's existing suite byverify-typescript.sh, and against a recording of the shipped package byrun-all.sh.npm run checkpasses locally (format, lint, types).npm run build:llmsif I toucheddocs/utilities.md— not applicable,docs/untouched.🤖 Generated with Claude Code
https://claude.ai/code/session_01UX1gTGeMTyoXQyr1qUoQKd
Generated by Claude Code